using System.Collections;
using System.Collections.Generic;
using UnityEngine;



[System.Serializable]
public class SkillInfo
{
    [Tooltip("技能id")]
    public int id;
    [Tooltip("技能名称")]
    public string name;
    [Tooltip("技能描述")]
    public string description;
    [Tooltip("冷却回合")]
    public int cooling_rounds;
    [Tooltip("技能图标")]
    public string icon;
    [Tooltip("最小使用距离")]
    public int minDistance;
    [Tooltip("最大使用距离")]
    public int maxDistance;
    [Tooltip("基础伤害")]
    public int baseDamage;
    [Tooltip("基础治疗")]
    public int baseHeal;
}

[CreateAssetMenu(menuName = "Config/SkillConfig")]
public class SkillConfig : ScriptableObject
{
    public List<SkillInfo> skills = new List<SkillInfo>();
    private Dictionary<int, SkillInfo> skillDict = new Dictionary<int, SkillInfo>();

    /// <summary>
    /// 初始化字典
    /// </summary>
    private void OnEnable()
    {
        // 清空并重新填充字典
        skillDict.Clear();
        
        foreach (var skill in skills)
        {
            if (skillDict.ContainsKey(skill.id))
            {
                Debug.LogError($"技能: {skill.name}, id: {skill.id} 已经存在，不能重复添加。");
            }
            else
            {
                skillDict.Add(skill.id, skill);
            }
        }
    }

    /// <summary>
    /// 查询技能信息
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    public SkillInfo GetSkillInfo(int id)
    {
        if (skillDict.ContainsKey(id))
        {
            return skillDict[id];
        }
        else
        {
            throw new System.Exception($"技能ID: {id} 不存在。");
        }
    }
}
